<template>
    <div>
        <h2>学生管理</h2>
        <Add @show="show" />
        <Update
            @show="show"
        />
        <Search @show="show" />
        <List
            :students="students"
            @show="show"
        />
        <Pagination :pagination="pagination" @show="show"></Pagination>
    </div>
</template>

<script>
import Add from "../components/student/Add";
import Update from "../components/student/Update";
import Search from "../components/student/Search";
import List from "../components/student/List";
import Pagination from "../components/student/Pagination";
import { find } from "../services/student";
export default {
    components: {
        Add,
        Update,
        Search,
        List,
        Pagination
    },
    data() {
        return {
            students: [],
            student: {},
            pagination:{},
            type: "",
            value: "",
        };
    },
    created() {
        this.show();
    },
    methods: {
        async show(params = {}) {
            if(params.type){
                this.type = params.type;
                this.value = params.value;
            }else{
                params.type = this.type;
                params.value = this.value;
            }
            let res = await find(params);
            this.students = res.rows;
            this.pagination = res;
        },
        setStudent(student) {
            this.student = student;
        }
    },
};
</script>

<style>
</style>